package org.yu.api.register;

import com.google.gson.annotations.Expose;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraftforge.items.wrapper.RecipeWrapper;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class LazyRecipe implements Recipe<RecipeWrapper> {

    public  ResourceLocation id;
    @Expose
    public final ResourceLocation type;

    public void setId(ResourceLocation id) {
        this.id = id;
    }

    protected LazyRecipe() {
        this.type = getSerializer().getRegistryName();
    }

    @Override
    public ResourceLocation getId() {
        return id;
    }

    @Override
    public boolean canCraftInDimensions(int pWidth, int pHeight) {
        return true;
    }
    @Nonnull
    protected abstract RecipeHolder<?> getRecipeHolder();

    @Override
    public RecipeSerializer<?> getSerializer() {
        return getRecipeHolder().serializer;
    }

    @Override
    public RecipeType<?> getType() {
        return getRecipeHolder().recipeType;
    }

}
